package com.design.designmode.struct.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @author hxl
 * @since 2023-04-17
 */
public class ShapeFactory {
    private Map<String, Shape> map = new HashMap<String, Shape>();


    public Shape getShape(String key) {
        if (!map.containsKey(key)) {
            map.put(key, new Circle(key));
            System.out.println("create color：" + key + " circle");
        }

        return map.get(key);
    }

}
